package scantask.containers.operationStanzas;

import scantask.containers.User;
import scantask.server.domainLayer.ControllerInterface;
import scantask.server.domainLayer.Exceptions.LoginException;

public class LoginStanza extends Stanza {

	private String _userName;
	private String _password;
	
	public LoginStanza(String userName, String password) {
		this._userName = userName;
		this._password = password;
	}

	@Override
	public String perform(ControllerInterface controller) {
		try {
			User user = controller.login(this._userName, this._password);
			scantask.server.utilities.logging.SingletonLogger.getLogger().warning("Sending User object to " + this._userName + " about login request");
			return this.parseToXML(user);
		} catch (LoginException e) {
			scantask.server.utilities.logging.SingletonLogger.getLogger().warning("Sending exception to " + this._userName + " about login request");
			scantask.server.utilities.logging.SingletonLogger.getLogger().warning(e.getErrorDescription());
			return this.parseToXML(e);
		}
	}
	


}
